package com.zxx.pattern.statePattern.state2;

/**
 * 预定状态房间可以入住、退订
 *
 * @author zxx on 2021/1/18
 */
public class BookedState implements State2 {

    Room2 hotelManagement;

    public BookedState(Room2 hotelManagement) {
        this.hotelManagement = hotelManagement;
    }

    @Override
    public void bookRoom() {
        System.out.println("该房间已近给预定了...");
    }

    @Override
    public void unsubscribeRoom() {
        System.out.println("退订成功,欢迎下次光临...");

        //变成空闲状态
        hotelManagement.setState2(hotelManagement.getFreeTimeState());
    }

    @Override
    public void checkInRoom() {
        System.out.println("入住成功...");

        //状态变成入住
        hotelManagement.setState2(hotelManagement.getCheckInState());
    }

    @Override
    public void checkOutRoom() {
        //不需要做操作
    }
}
